package com.ele.client.activity.editor;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

public class EditorPlace extends Place {

    private Long sectionId;

    public EditorPlace(String token) {
        try {
            this.sectionId = Long.parseLong(token);
        } catch (NumberFormatException e) {
            this.sectionId = null;
        }
    }

    public EditorPlace(long sectionId) {
        this.sectionId = sectionId;
    }

    public Long getSectionId() {
        return sectionId;
    }

    public static class Tokenizer implements PlaceTokenizer<EditorPlace> {
        @Override
        public EditorPlace getPlace(String token) {
            return new EditorPlace(token);
        }

        @Override
        public String getToken(EditorPlace place) {
            return String.valueOf(place.getSectionId());
        }
    }
}
